<?php

namespace App\Http\Controllers;

use App\Library\Requests\Login\LoginDouyinRequest;
use App\Library\Requests\Login\LoginMobileRequest;
use App\Library\Requests\Login\LoginPasswordRequest;
use App\Library\Requests\Login\LoginSendCodeRequest;
use App\Library\Requests\Login\LoginWechatRequest;
use App\Library\Service\LoginService;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\JsonResponse;

class LoginController extends BaseController
{
    /**
     * @param LoginService $service
     */
    public function __construct(LoginService $service)
    {
        $this->service = $service;
    }

    /**
     * 发送验证码
     * @param LoginSendCodeRequest $request
     * @return JsonResponse
     */
    public function sendCode(LoginSendCodeRequest $request): JsonResponse
    {
        return $this->service->sendCode($request);
    }

    /**
     * 手机号登录
     * @param LoginMobileRequest $request
     * @return JsonResponse
     * @throws Exception
     */
    public function mobile(LoginMobileRequest $request): JsonResponse
    {
        return $this->service->mobile($request);
    }

    /**
     * 微信登录
     * @param LoginWechatRequest $request
     * @return JsonResponse
     * @throws GuzzleException|Exception
     */
    public function wechat(LoginWechatRequest $request): JsonResponse
    {
        return $this->service->wechat($request);
    }

    /**
     * 抖音登录
     * @param LoginDouyinRequest $request
     * @return JsonResponse
     * @throws GuzzleException|Exception
     */
    public function douyin(LoginDouyinRequest $request): JsonResponse
    {
        return $this->service->douyin($request);
    }

    /**
     * 密码登录
     * @param LoginPasswordRequest $request
     * @return JsonResponse
     */
    public function password(LoginPasswordRequest $request): JsonResponse
    {
        return $this->service->password($request);
    }
}
